package cn.yunhe.controller;

import cn.yunhe.services.IBookService;
import cn.yunhe.services.impl.BookService;
import cn.yunhe.utils.BaseAction;
import lombok.Data;
import net.sf.json.JSONArray;

import java.io.IOException;
import java.io.PrintWriter;

@Data
public class QueryAction extends BaseAction {
    private String keyword;
    JSONArray jsonArray = new JSONArray();
    IBookService iBookService = new BookService();

    public String quaryByName() throws IOException {
        PrintWriter out = getResponse().getWriter();
        jsonArray = iBookService.getBookByName(keyword);
        out.print(jsonArray);
        return null;
    }

    public String quaryByAuthor() throws IOException {
        PrintWriter out = getResponse().getWriter();
        jsonArray = iBookService.getBookByAuthor(keyword);
        out.print(jsonArray);
        return null;
    }

    public String quaryByPubl() throws IOException {
        PrintWriter out = getResponse().getWriter();
        jsonArray = iBookService.getBookByPubl(keyword);
        out.print(jsonArray);
        return null;
    }


}
